import Koa from 'koa';
import config from "./config";
import log4js from 'log4js';
import errorHandler from './middlewares/errorHandler';

const app = new Koa();

// app.use(async ctx => {
//   ctx.body = 'Hello World';
// });

log4js.configure({
  appenders: { err: { type: 'file', filename: 'err.log' } },
  categories: { default: { appenders: ['err'], level: 'error' } }
});
const logger = log4js.getLogger('err');
errorHandler.error(app,logger);

app.listen(config.port, () => {
  console.log(`myweb listening on ${config.port}`);
});